<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

/**
 * 留言或建议📝
 * 
 */
class Gbook extends Api
{

    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

  

    /**
     * 在线留言建议
     * 
     * @ApiSummary  (或者直接加QQ496631085)
     *
     *
     * @param string $content
     * @param string $nickname
     * @return void
     */
    public function url_de_qrcode($content=null,$nickname=null)
    {
        if($content){
            $data['ip'] = $this->request->ip();
            $data['content'] = $content;
            $res = Db::name('gbook')->where($data)->find();
            if(!$res){
                $data['time'] = time();
                $data['nickname'] = $nickname;
                Db::name('gbook')->insert($data);
                $this->success('留言成功', $data);
            }else{
                $this->error('已有该留言！',date('Y-m-d H:i:s',$res['time']));
            }
            
        }else{
            $this->error('没有内容哦！');
        }
        
    }


    
  


   

}
